home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / envoy / netprobe_4_24.lha / NetProbe / src / stuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-04  |  4.6 KB  |  167 lines

  1. //
  2. //  $Log: stuff.c,v $
  3. //  Revision 1.4  1994/10/04  01:02:02  hakan
  4. //  PROGDIR:-Abhängigkeit und Owner-bug beseitigt
  5. //
  6. //  Revision 1.3  1994/08/15  22:54:50  hakan
  7. //  SaveList() is fully functional.
  8. //
  9. //  Revision 1.2  1994/07/12  22:18:21  hakan
  10. //  DecodeATTNFlags and DecodeChipRevBits recreated
  11. //
  12. //  Revision 1.1  1994/07/12  21:54:17  hakan
  13. //  Initial revision
  14. //
  15. //
  16.  
  17. static char* RCSId = "$Id: stuff.c,v 1.4 1994/10/04 01:02:02 hakan Exp $";
  18.  
  19. #include "extern.h"
  20. #include <exec/execbase.h>
  21. #include <graphics/gfxbase.h>
  22.  
  23.  
  24.  
  25. char* DecodeATTNFlags (long flags)
  26. {
  27.     static char buf [100];
  28.     char* p;
  29.     char* f;
  30.  
  31.                            p = "68000";
  32.     if (flags & AFF_68010) p = "68010";
  33.     if (flags & AFF_68020) p = "68020";
  34.     if (flags & AFF_68030) p = "68030";
  35.     if (flags & AFF_68040) p = "68040";
  36.  
  37.                            f = "\0";
  38.     if (flags & AFF_68881) f = ", 68881";
  39.     if (flags & AFF_68882) f = ", 68882";
  40.  
  41.     sprintf (buf, "%s%s", p, f);
  42.  
  43.     return (buf);
  44. }
  45.  
  46.  
  47.  
  48. char* DecodeChipRevBits (long flags)
  49. {
  50.     static char* c;
  51.  
  52.  
  53.     flags &= SETCHIPREV_AA;
  54.  
  55.                                                     c = "Classic Chipset";
  56.     if ((flags & SETCHIPREV_A) == SETCHIPREV_A)     c = "Fat Agnus";
  57.     if ((flags & SETCHIPREV_ECS) == SETCHIPREV_ECS) c = "Extended Chip Set";
  58.     if ((flags & SETCHIPREV_AA) == SETCHIPREV_AA)   c = "Advanced Amiga";
  59.  
  60.     return (c);
  61. }
  62.  
  63.  
  64.  
  65. void SaveList (char* FileName)
  66. {
  67.     FILE*           outf;
  68.     struct Node*    work;
  69.     struct List*    list;
  70.     struct Node*    innerWork;
  71.     struct List*    innerList;
  72.  
  73.  
  74.     if (FileName)
  75.     {
  76.         outf = fopen (FileName, "w");
  77.     }
  78.     else
  79.     {
  80.         outf = stdout;
  81.     }
  82.  
  83.     if (!!outf)
  84.     {
  85.         list = Realms ();
  86.         if (!(IsListEmpty(list)))
  87.         {
  88.             fprintf (outf, "Realms:\n");
  89.  
  90.             for (work = list->lh_Head; work->ln_Succ; work = work->ln_Succ)
  91.             {
  92.                 fprintf (outf, "    %s\n", work->ln_Name);
  93.             }
  94.  
  95.             fprintf (outf, "\n");
  96.         }
  97.  
  98.         list = Hosts ();
  99.         if (!(IsListEmpty(list)))
  100.         {
  101.             fprintf (outf, "Hosts:\n");
  102.  
  103.             for (work = list->lh_Head; work->ln_Succ; work = work->ln_Succ)
  104.             {
  105.                 Host* h = (Host*) work;
  106.  
  107.                 if (h->HostName)
  108.                     fprintf (outf, "    Hostname:     %s\n", h->HostName);
  109.  
  110.                 if (h->Owner)
  111.                     if (h->Owner[0])
  112.                         fprintf (outf, "    Owner:        %s\n", h->Owner);
  113.  
  114.                 if (h->IPAddr)
  115.                     fprintf (outf, "    IP-Address:   %ld.%ld.%ld.%ld\n", ((h->IPAddr >> 24) & 0xff), ((h->IPAddr >> 16) & 0xff), ((h->IPAddr >> 8) & 0xff), (h->IPAddr & 0xff));
  116.  
  117.                 if (h->KickVersion)
  118.                     fprintf (outf, "    Kickstart:    %ld.%ld\n", ((h->KickVersion >> 16) & 0xffff), (h->KickVersion & 0xffff));
  119.  
  120.                 if (h->WBVersion)
  121.                     fprintf (outf, "    Workbench:    %ld.%ld\n", ((h->WBVersion >> 16) & 0xffff), (h->WBVersion & 0xffff));
  122.  
  123.                 if (h->MaxFastMem)
  124.                     fprintf (outf, "    Memory:       %ld K Fast,  %ld K Chip\n", (h->MaxFastMem) / 1024, (h->MaxChipMem) / 1024);
  125.  
  126.                 if (h->NIPCVersion)
  127.                     fprintf (outf, "    NIPC Version: %ld.%ld\n", ((h->NIPCVersion >> 16) & 0xff), (h->NIPCVersion & 0xff));
  128.  
  129.                 if (h->ATTNFlags)
  130.                     fprintf (outf, "    Processor:    %s\n", DecodeATTNFlags (h->ATTNFlags));
  131.  
  132.                 if (h->ChipRevBits)
  133.                     fprintf (outf, "    Custom Chips: %s\n", DecodeChipRevBits (h->ChipRevBits));
  134.  
  135.                 innerList = &(h->Services);
  136.                 if (!(IsListEmpty(innerList)))
  137.                 {
  138.                     long num = 0;
  139.  
  140.                     for (innerWork = innerList->lh_Head; innerWork->ln_Succ; innerWork = innerWork->ln_Succ)
  141.                     {
  142.                         fprintf (outf, "%s%s\n", (num++) ? "                  " : "    Services:     ", innerWork->ln_Name);
  143.                     }
  144.                 }
  145.  
  146.                 innerList = &(h->Entities);
  147.                 if (!(IsListEmpty(innerList)))
  148.                 {
  149.                     long num = 0;
  150.  
  151.                     for (innerWork = innerList->lh_Head; innerWork->ln_Succ; innerWork = innerWork->ln_Succ)
  152.                     {
  153.                         fprintf (outf, "%s%s\n", (num++) ? "                  " : "    Entities:     ", innerWork->ln_Name);
  154.                     }
  155.                 }
  156.  
  157.                 fprintf (outf, "\n");
  158.             }
  159.         }
  160.  
  161.         if (FileName)
  162.         {
  163.             fclose (outf);
  164.         }
  165.     }
  166. }
  167.